/**
 * @author harae Feng 
 * @date 2019-09-24 15:41:35 
 * @Last Modified by: harae Feng
 * @Last Modified time: 2019-10-18 17:09:08
 * @Describe 抖音-热点榜
 */


const fetch = require('../../util/fetchUtil').fetchRequest
const ResultAPI = require('../../routes/api/resultAPI')
const CatchHandle = require('../../routes/api/apicatch')


/**
 * 热点榜
 */
async function ciHot(options){
    let url = `https://www.iesdouyin.com/web/api/v2/hotsearch/billboard/word/`
    let res = await fetch(url)
    let resJSON = await res.json()
    return resJSON
}

async function ciHotAPI(ctx){
    try {
        let parms = ctx.query.parms || {}
        let __Options = Object.assign(parms, require('./__parms.js'))
        let resJSON = await ciHot(__Options)
        if(resJSON.status_code === 0){
            return new ResultAPI(0, {}, resJSON)
        }else{
            return new ResultAPI(10003)
        }       
    } catch (error) {
        return CatchHandle(__dirname, __filename, error)
    }
}

module.exports = {
    ciHot: ciHot
}